﻿using System;
using System.Collections.Generic;
using System.Web;
using AspNetInfo.Core;
using AspNetInfo.Helpers;
using CommonGenius.Collections;
using System.Data;

namespace AspNetInfo.Detectors
{
    public class ProcessorDetector : IDetector
    {
        public DataTable Detect(EnvironmentPermissions permissions)
        {
            var dt = DetectorHelper.MakeResultTable();
            if (permissions.TrustLevel > AspNetHostingPermissionLevel.Medium)
            {
                dt.Rows.Add("Number of Processors", Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"));
                dt.Rows.Add("Processor Id", Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER"));
                SystemInfo.CpuInfo cpu = SystemInfo.Cpu;
                dt.Rows.Add("Processor Type", cpu.dwProcessorType.ToString());
                dt.Rows.Add("Processor Level", cpu.dwProcessorLevel.ToString());
                dt.Rows.Add("Processor OEM Id", cpu.dwOemId.ToString());
                dt.Rows.Add("Page Size", cpu.dwPageSize.ToString());
            }
            return dt;
        }
        public string Name
        {
            get { return "Processor"; }
        }

        public string Description
        {
            get { return String.Empty; }
        }

        public string TabName
        {
            get { return Tabs.General; }
        }
    }
}
